package com.chendechao.model_home.ui

import com.chendechao.lib_base.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(val repository: HomeRepository) : BaseViewModel<HomeUIState, HomeIntent>(HomeUIState()){
    override suspend fun handleEvent(event: HomeIntent) {
        when(event){
            is HomeIntent.GetRecommendMutilVideo -> TODO()
            is HomeIntent.GetSimpleType -> getTabLayoutData()
            is HomeIntent.SearchData -> TODO()
        }
    }
    private suspend fun getTabLayoutData(){
        val res = repository.getTabLayoutData()
        res.onSuccess {
            updateState(HomeUIState(simpleType = it.simpleType, isSucess = true))
        }.onFailure {

        }
    }

}